package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.ChanPinXinXi;
import com.ysd.util.DBManager;

public class XSTuiJianDaoImpl {
	public List<ChanPinXinXi> getCPTuiJian(){
		List<ChanPinXinXi> cpxxList=new ArrayList<ChanPinXinXi>();
		Connection conn=DBManager.getConnection();
		Statement st=null;
		ResultSet rs=null;
		ChanPinXinXi cp=null;
		
		try {
			st=conn.createStatement();
			rs=st.executeQuery("select * from chanpinxinxi order by rand() limit 6");
			while(rs.next()) {
				int cpId=rs.getInt("cPId");
				String tp=rs.getString("tuPian");
				String cpName=rs.getString("cPName");
				int shouJia=rs.getInt("cPShouJia");
				String pp=rs.getString("pinPai");
				String dz=rs.getString("shiFouDZ");
				String xqtpp=rs.getString("xQTpp");
				String xqtp=rs.getString("xQTp");
				String ys=rs.getString("chanPinYanSe");
				int fl=rs.getInt("fenLeiID");
				cp=new ChanPinXinXi(cpId, tp, cpName, shouJia, pp, dz, xqtpp, xqtp, ys, fl);
				cpxxList.add(cp);
			}
			return cpxxList;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		} finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
